import { formulaTransform, formulaVariableReplace } from '../util/formula-transform';

/**
 * 默认使用的相关公式
 */
export const defaultFormula: Array<[string, string | ReturnType<typeof formulaVariableReplace>]> = [
  ['KX', '#KMFX'],
  [
    'W',
    formulaVariableReplace(
      '#KMFX==0?#W+#ST_ZFX:#KMFX==1?#W+#ST_YFX:#KMFX==2?#H+#ST_SFX:#KMFX==3?#H+#ST_XFX:#W+#ST_ZFX'
    ),
  ],
  ['H', formulaVariableReplace('#KMFX==0?#H:#KMFX==1?#H:#KMFX==2?#W:#KMFX==3?#W:#H')],
  ['D', '#D'],
  ['ZY', '#KMFX==2?#SY:#KMFX==3?#XY:#ZY'],
  ['YY', '#KMFX==2?#SY:#KMFX==3?#XY:#YY'],
  ['SY', '#KMFX==2?#SY:#KMFX==3?#SY:#SY'],
  ['XY', '#KMFX==2?#XY:#KMFX==3?#XY:#XY'],
  /*['MJPP', '#MJPP'],
    /*['MJLX', '#MJLX'],
    ['ANFTQ', '#ANFTQ'],
    ['MJSL', '#MJSL'],
    ...Array.from({ length: 6 }).map((value, index) => {
        return [`MJ${index + 1}`, `#MJ${index+1}`];
    }),*/
  /*['LZQ', '#LZQ'],
    ['LZQWZ', '#LZQWZ'],
    ['LZQBZ', '#LZQBZ'],
    ['LAQKCW', '#LAQKCW'],
    ['LZQKCD', '#LZQKCD'],
    ['YMMX', '#YMMX'],*/
].map((i) => {
  return [i[0], typeof i[1] === 'string' ? formulaTransform(i[1]) : i[1]] as [
    string,
    string | ReturnType<typeof formulaVariableReplace>
  ];
});

/**
 * 默认位置公式
 */
export const defaultPositionFormula = {
  x: formulaVariableReplace('#KMFX==0?-#ST_ZFX:#KMFX==1?0:#KMFX==2?0:#KMFX==3?#W:-#ST_ZFX'),
  z: formulaVariableReplace('#KMFX==0?0:#KMFX==1?0:#KMFX==2?#H+#ST_SFX:#KMFX==3?0-#ST_XFX:0'),
  y: '0',
};

/**
 * 默认旋转公式
 */
export const defaultRotationFormula = {
  x: '0',
  z: '0',
  y: formulaTransform('#KMFX==2?90:#KMFX==3?-90:0'),
};
